#    pythonequations is a collection of equations expressed as Python classes
#    Copyright (C) 2008 James R. Phillips
#    2548 Vera Cruz Drive
#    Birmingham, AL 35235 USA
#    email: zunzun@zunzun.com
#
#    License: BSD-style (see LICENSE.txt in main source directory)
#    Version info: $Id: LegendrePolynomial.py 274 2010-09-29 13:16:14Z zunzun.com $

import pythonequations, pythonequations.EquationBaseClasses, pythonequations.ExtraCodeForEquationBaseClasses
import numpy
numpy.seterr(all = 'raise') # numpy raises warnings, convert to exceptions to trap them


def cppCodeGeneratorForLegendrePolynomials(n, cosineFlag):
    # see http://en.wikipedia.org/wiki/Legendre_polynomials'
    if cosineFlag:
        x = 'cos(x_in)'
    else:
        x = 'x_in'

    if n == 0:
        return "1.0"
    elif n == 1:
        return "x_in"
    elif n == 2:
        return "(1.0 / 2.0) * (3.0*pow(" + x + ", 2.0) - 1.0)"
    elif n == 3:
         return "(1.0 / 2.0) * (5.0*pow(" + x + ", 3.0) - 3.0*" + x + ")"
    elif n == 4:
        return "(1.0 / 8.0) * (35.0*pow(" + x + ", 4.0) - 30.0*pow(" + x + ", 2.0) + 3)"
    elif n == 5:
        return "(1.0 / 8.0) * (63.0*pow(" + x + ", 5.0) - 70.0*pow(" + x + ", 3.0) + 15.0*" + x + ")"
    elif n == 6:
        return "(1.0 / 16.0) * (231.0*pow(" + x + ", 6.0) - 315.0*pow(" + x + ", 4.0) + 105.0*pow(" + x + ", 2.0) - 5)"
    elif n == 7:
        return "(1.0 / 16.0) * (429.0*pow(" + x + ", 7.0) - 693.0*pow(" + x + ", 5.0) + 315.0*pow(" + x + ", 3.0) - 35.0*" + x + ")"
    elif n == 8:
        return "(1.0 / 128.0) * (6435.0*pow(" + x + ", 8.0) - 12012.0*pow(" + x + ", 6.0) + 6930.0*pow(" + x + ", 4.0) - 1260.0*pow(" + x + ", 2.0) + 35.0)"
    elif n == 9:
        return "(1.0 / 128.0) * (12155.0*pow(" + x + ", 9.0) - 25740.0*pow(" + x + ", 7.0) + 18018.0*pow(" + x + ", 5.0) - 4620.0*pow(" + x + ", 3.0) + 315.0*" + x + ")"
    elif n == 10:
        return "(1.0 / 256.0) * (46189.0*pow(" + x + ", 10.0) - 109395.0*pow(" + x + ", 8.0) + 90090.0*pow(" + x + ", 6.0) - 30030.0*pow(" + x + ", 4.0) + 3465.0*pow(" + x + ", 2.0) - 63.0)"
    else:
        raise Exception("Legendre Polynomial Degree of " + str(n) + " is too high, please use a degree of 10 or less.")


    
class SecondDegreeLegendrePolynomial2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Legendre Polynomial A - Second Degree"
    _HTML = "y = a + bx + cP<sub>2</sub>"
    webCitationLink = 'http://en.wikipedia.org/wiki/Legendre_polynomials'
    coefficientDesignatorTuple = ('a', 'b', 'c')
    LinearSSQSolverFlag = 1
    function_cpp_code = 'temp = coeff[0] + coeff[1] * _id[_cwo[1]+i] + coeff[2] * _id[_cwo[2]+i];'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[2, 0]), [2, 0]])


    def SpecificCodeCPP(self):
        s  = "\t// see http://en.wikipedia.org/wiki/Legendre_polynomials\n"
        s += "\ttemp += a + b * x_in;\n"
        s += "\ttemp += c * (" + cppCodeGeneratorForLegendrePolynomials(2, 0) + ");\n"
        return s



class ThirdDegreeLegendrePolynomial2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Legendre Polynomial B - Third Degree"
    _HTML = "y = a + bx + cP<sub>2</sub> + dP<sub>3</sub>"
    webCitationLink = 'http://en.wikipedia.org/wiki/Legendre_polynomials'
    coefficientDesignatorTuple = ('a', 'b', 'c', 'd')
    LinearSSQSolverFlag = 1
    function_cpp_code = 'temp = coeff[0] + coeff[1] * _id[_cwo[1]+i] + coeff[2] * _id[_cwo[2]+i] + coeff[3] * _id[_cwo[3]+i];'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[2, 0]), [2, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[3, 0]), [3, 0]])


    def SpecificCodeCPP(self):
        s  = "\t// see http://en.wikipedia.org/wiki/Legendre_polynomials\n"
        s += "\ttemp += a + b * x_in;\n"
        s += "\ttemp += c * (" + cppCodeGeneratorForLegendrePolynomials(2, 0) + ");\n"
        s += "\ttemp += d * (" + cppCodeGeneratorForLegendrePolynomials(3, 0) + ");\n"
        return s



class FourthDegreeLegendrePolynomial2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Legendre Polynomial C - Fourth Degree"
    _HTML = "y = a + bx + cP<sub>2</sub> + dP<sub>3</sub> + fP<sub>4</sub>"
    webCitationLink = 'http://en.wikipedia.org/wiki/Legendre_polynomials'
    coefficientDesignatorTuple = ('a', 'b', 'c', 'd', 'f')
    LinearSSQSolverFlag = 1
    function_cpp_code = 'temp = coeff[0] + coeff[1] * _id[_cwo[1]+i] + coeff[2] * _id[_cwo[2]+i] + coeff[3] * _id[_cwo[3]+i] + coeff[4] * _id[_cwo[4]+i];'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[2, 0]), [2, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[3, 0]), [3, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[4, 0]), [4, 0]])


    def SpecificCodeCPP(self):
        s  = "\t// see http://en.wikipedia.org/wiki/Legendre_polynomials\n"
        s += "\ttemp += a + b * x_in;\n"
        s += "\ttemp += c * (" + cppCodeGeneratorForLegendrePolynomials(2, 0) + ");\n"
        s += "\ttemp += d * (" + cppCodeGeneratorForLegendrePolynomials(3, 0) + ");\n"
        s += "\ttemp += f * (" + cppCodeGeneratorForLegendrePolynomials(4, 0) + ");\n"
        return s



class FifthDegreeLegendrePolynomial2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Legendre Polynomial D - Fifth Degree"
    _HTML = "y = a + bx + cP<sub>2</sub> + dP<sub>3</sub> + fP<sub>4</sub> + gP<sub>5</sub>"
    webCitationLink = 'http://en.wikipedia.org/wiki/Legendre_polynomials'
    coefficientDesignatorTuple = ('a', 'b', 'c', 'd', 'f', 'g')
    LinearSSQSolverFlag = 1
    function_cpp_code = 'temp = coeff[0] + coeff[1] * _id[_cwo[1]+i] + coeff[2] * _id[_cwo[2]+i] + coeff[3] * _id[_cwo[3]+i] + coeff[4] * _id[_cwo[4]+i] + coeff[5] * _id[_cwo[5]+i];'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[2, 0]), [2, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[3, 0]), [3, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[4, 0]), [4, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[5, 0]), [5, 0]])


    def SpecificCodeCPP(self):
        s  = "\t// see http://en.wikipedia.org/wiki/Legendre_polynomials\n"
        s += "\ttemp += a + b * x_in;\n"
        s += "\ttemp += c * (" + cppCodeGeneratorForLegendrePolynomials(2, 0) + ");\n"
        s += "\ttemp += d * (" + cppCodeGeneratorForLegendrePolynomials(3, 0) + ");\n"
        s += "\ttemp += f * (" + cppCodeGeneratorForLegendrePolynomials(4, 0) + ");\n"
        s += "\ttemp += g * (" + cppCodeGeneratorForLegendrePolynomials(5, 0) + ");\n"
        return s



class SixthDegreeLegendrePolynomial2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Legendre Polynomial E - Sixth Degree"
    _HTML = "y = a + bx + cP<sub>2</sub> + dP<sub>3</sub> + fP<sub>4</sub> + gP<sub>5</sub> + hP<sub>6</sub>"
    webCitationLink = 'http://en.wikipedia.org/wiki/Legendre_polynomials'
    coefficientDesignatorTuple = ('a', 'b', 'c', 'd', 'f', 'g', 'h')
    LinearSSQSolverFlag = 1
    function_cpp_code = 'temp = coeff[0] + coeff[1] * _id[_cwo[1]+i] + coeff[2] * _id[_cwo[2]+i] + coeff[3] * _id[_cwo[3]+i] + coeff[4] * _id[_cwo[4]+i] + coeff[5] * _id[_cwo[5]+i] + coeff[6] * _id[_cwo[6]+i];'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[2, 0]), [2, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[3, 0]), [3, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[4, 0]), [4, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[5, 0]), [5, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[6, 0]), [6, 0]])


    def SpecificCodeCPP(self):
        s  = "\t// see http://en.wikipedia.org/wiki/Legendre_polynomials\n"
        s += "\ttemp += a + b * x_in;\n"
        s += "\ttemp += c * (" + cppCodeGeneratorForLegendrePolynomials(2, 0) + ");\n"
        s += "\ttemp += d * (" + cppCodeGeneratorForLegendrePolynomials(3, 0) + ");\n"
        s += "\ttemp += f * (" + cppCodeGeneratorForLegendrePolynomials(4, 0) + ");\n"
        s += "\ttemp += g * (" + cppCodeGeneratorForLegendrePolynomials(5, 0) + ");\n"
        s += "\ttemp += h * (" + cppCodeGeneratorForLegendrePolynomials(6, 0) + ");\n"
        return s



class SeventhDegreeLegendrePolynomial2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Legendre Polynomial F - Seventh Degree"
    _HTML = "y = a + bx + cP<sub>2</sub> + dP<sub>3</sub> + fP<sub>4</sub> + gP<sub>5</sub> + hP<sub>6</sub> + iP<sub>7</sub>"
    webCitationLink = 'http://en.wikipedia.org/wiki/Legendre_polynomials'
    coefficientDesignatorTuple = ('a', 'b', 'c', 'd', 'f', 'g', 'h', 'i')
    LinearSSQSolverFlag = 1
    function_cpp_code = 'temp = coeff[0] + coeff[1] * _id[_cwo[1]+i] + coeff[2] * _id[_cwo[2]+i] + coeff[3] * _id[_cwo[3]+i] + coeff[4] * _id[_cwo[4]+i] + coeff[5] * _id[_cwo[5]+i] + coeff[6] * _id[_cwo[6]+i] + coeff[7] * _id[_cwo[7]+i];'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[2, 0]), [2, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[3, 0]), [3, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[4, 0]), [4, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[5, 0]), [5, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[6, 0]), [6, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[7, 0]), [7, 0]])


    def SpecificCodeCPP(self):
        s  = "\t// see http://en.wikipedia.org/wiki/Legendre_polynomials\n"
        s += "\ttemp += a + b * x_in;\n"
        s += "\ttemp += c * (" + cppCodeGeneratorForLegendrePolynomials(2, 0) + ");\n"
        s += "\ttemp += d * (" + cppCodeGeneratorForLegendrePolynomials(3, 0) + ");\n"
        s += "\ttemp += f * (" + cppCodeGeneratorForLegendrePolynomials(4, 0) + ");\n"
        s += "\ttemp += g * (" + cppCodeGeneratorForLegendrePolynomials(5, 0) + ");\n"
        s += "\ttemp += h * (" + cppCodeGeneratorForLegendrePolynomials(6, 0) + ");\n"
        s += "\ttemp += h * (" + cppCodeGeneratorForLegendrePolynomials(7, 0) + ");\n"
        return s



class EighthDegreeLegendrePolynomial2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Legendre Polynomial G - Eighth Degree"
    _HTML = "y = a + bx + cP<sub>2</sub> + dP<sub>3</sub> + fP<sub>4</sub> + gP<sub>5</sub> + hP<sub>6</sub> + iP<sub>7</sub> + jP<sub>8</sub>"
    webCitationLink = 'http://en.wikipedia.org/wiki/Legendre_polynomials'
    coefficientDesignatorTuple = ('a', 'b', 'c', 'd', 'f', 'g', 'h', 'i', 'j')
    LinearSSQSolverFlag = 1
    function_cpp_code = 'temp = coeff[0] + coeff[1] * _id[_cwo[1]+i] + coeff[2] * _id[_cwo[2]+i] + coeff[3] * _id[_cwo[3]+i] + coeff[4] * _id[_cwo[4]+i] + coeff[5] * _id[_cwo[5]+i] + coeff[6] * _id[_cwo[6]+i] + coeff[7] * _id[_cwo[7]+i] + coeff[8] * _id[_cwo[8]+i];'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[2, 0]), [2, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[3, 0]), [3, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[4, 0]), [4, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[5, 0]), [5, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[6, 0]), [6, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[7, 0]), [7, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[8, 0]), [8, 0]])


    def SpecificCodeCPP(self):
        s  = "\t// see http://en.wikipedia.org/wiki/Legendre_polynomials\n"
        s += "\ttemp += a + b * x_in;\n"
        s += "\ttemp += c * (" + cppCodeGeneratorForLegendrePolynomials(2, 0) + ");\n"
        s += "\ttemp += d * (" + cppCodeGeneratorForLegendrePolynomials(3, 0) + ");\n"
        s += "\ttemp += f * (" + cppCodeGeneratorForLegendrePolynomials(4, 0) + ");\n"
        s += "\ttemp += g * (" + cppCodeGeneratorForLegendrePolynomials(5, 0) + ");\n"
        s += "\ttemp += h * (" + cppCodeGeneratorForLegendrePolynomials(6, 0) + ");\n"
        s += "\ttemp += h * (" + cppCodeGeneratorForLegendrePolynomials(7, 0) + ");\n"
        s += "\ttemp += h * (" + cppCodeGeneratorForLegendrePolynomials(8, 0) + ");\n"
        return s



class NinthDegreeLegendrePolynomial2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Legendre Polynomial H - Ninth Degree"
    _HTML = "y = a + bx + cP<sub>2</sub> + dP<sub>3</sub> + fP<sub>4</sub> + gP<sub>5</sub> + hP<sub>6</sub> + iP<sub>7</sub> + jP<sub>8</sub> + kP<sub>9</sub>"
    webCitationLink = 'http://en.wikipedia.org/wiki/Legendre_polynomials'
    coefficientDesignatorTuple = ('a', 'b', 'c', 'd', 'f', 'g', 'h', 'i', 'j', 'k')
    LinearSSQSolverFlag = 1
    function_cpp_code = 'temp = coeff[0] + coeff[1] * _id[_cwo[1]+i] + coeff[2] * _id[_cwo[2]+i] + coeff[3] * _id[_cwo[3]+i] + coeff[4] * _id[_cwo[4]+i] + coeff[5] * _id[_cwo[5]+i] + coeff[6] * _id[_cwo[6]+i] + coeff[7] * _id[_cwo[7]+i] + coeff[8] * _id[_cwo[8]+i] + coeff[9] * _id[_cwo[9]+i];'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[2, 0]), [2, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[3, 0]), [3, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[4, 0]), [4, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[5, 0]), [5, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[6, 0]), [6, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[7, 0]), [7, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[8, 0]), [8, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[9, 0]), [9, 0]])


    def SpecificCodeCPP(self):
        s  = "\t// see http://en.wikipedia.org/wiki/Legendre_polynomials\n"
        s += "\ttemp += a + b * x_in;\n"
        s += "\ttemp += c * (" + cppCodeGeneratorForLegendrePolynomials(2, 0) + ");\n"
        s += "\ttemp += d * (" + cppCodeGeneratorForLegendrePolynomials(3, 0) + ");\n"
        s += "\ttemp += f * (" + cppCodeGeneratorForLegendrePolynomials(4, 0) + ");\n"
        s += "\ttemp += g * (" + cppCodeGeneratorForLegendrePolynomials(5, 0) + ");\n"
        s += "\ttemp += h * (" + cppCodeGeneratorForLegendrePolynomials(6, 0) + ");\n"
        s += "\ttemp += h * (" + cppCodeGeneratorForLegendrePolynomials(7, 0) + ");\n"
        s += "\ttemp += h * (" + cppCodeGeneratorForLegendrePolynomials(8, 0) + ");\n"
        s += "\ttemp += h * (" + cppCodeGeneratorForLegendrePolynomials(9, 0) + ");\n"
        return s



class TenthDegreeLegendrePolynomial2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Legendre Polynomial I - Tenth Degree"
    _HTML = "y = a + bx + cP<sub>2</sub> + dP<sub>3</sub> + fP<sub>4</sub> + gP<sub>5</sub> + hP<sub>6</sub> + iP<sub>7</sub> + jP<sub>8</sub> + kP<sub>9</sub> + mP<sub>10</sub>"
    webCitationLink = 'http://en.wikipedia.org/wiki/Legendre_polynomials'
    coefficientDesignatorTuple = ('a', 'b', 'c', 'd', 'f', 'g', 'h', 'i', 'j', 'k', 'm')
    LinearSSQSolverFlag = 1
    function_cpp_code = 'temp = coeff[0] + coeff[1] * _id[_cwo[1]+i] + coeff[2] * _id[_cwo[2]+i] + coeff[3] * _id[_cwo[3]+i] + coeff[4] * _id[_cwo[4]+i] + coeff[5] * _id[_cwo[5]+i] + coeff[6] * _id[_cwo[6]+i] + coeff[7] * _id[_cwo[7]+i] + coeff[8] * _id[_cwo[8]+i] + coeff[9] * _id[_cwo[9]+i] + coeff[10] * _id[_cwo[10]+i];'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[2, 0]), [2, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[3, 0]), [3, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[4, 0]), [4, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[5, 0]), [5, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[6, 0]), [6, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[7, 0]), [7, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[8, 0]), [8, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[9, 0]), [9, 0]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreX(NameOrValueFlag=1, args=[10, 0]), [10, 0]])


    def SpecificCodeCPP(self):
        s  = "\t// see http://en.wikipedia.org/wiki/Legendre_polynomials\n"
        s += "\ttemp += a + b * x_in;\n"
        s += "\ttemp += c * (" + cppCodeGeneratorForLegendrePolynomials(2, 0) + ");\n"
        s += "\ttemp += d * (" + cppCodeGeneratorForLegendrePolynomials(3, 0) + ");\n"
        s += "\ttemp += f * (" + cppCodeGeneratorForLegendrePolynomials(4, 0) + ");\n"
        s += "\ttemp += g * (" + cppCodeGeneratorForLegendrePolynomials(5, 0) + ");\n"
        s += "\ttemp += h * (" + cppCodeGeneratorForLegendrePolynomials(6, 0) + ");\n"
        s += "\ttemp += h * (" + cppCodeGeneratorForLegendrePolynomials(7, 0) + ");\n"
        s += "\ttemp += h * (" + cppCodeGeneratorForLegendrePolynomials(8, 0) + ");\n"
        s += "\ttemp += h * (" + cppCodeGeneratorForLegendrePolynomials(9, 0) + ");\n"
        s += "\ttemp += h * (" + cppCodeGeneratorForLegendrePolynomials(10, 0) + ");\n"
        return s



class GammaRayAngularDistributionDegreesA2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Gamma Ray Angular Distribution (degrees) A"
    _HTML = "y = A0 + A2 * P<sub>2</sub>(cos(theta))"
    coefficientDesignatorTuple = ('A0', 'A2')
    LinearSSQSolverFlag = 1
    function_cpp_code = 'temp = coeff[0] + coeff[1] * _id[_cwo[1]+i];'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreCosineDegreesX(NameOrValueFlag=1, args=[2]), [2]])


    def SpecificCodeCPP(self):
        s  = "\t// see http://en.wikipedia.org/wiki/Legendre_polynomials\n"
        s += "\ttemp += A0 + A2 * (" + cppCodeGeneratorForLegendrePolynomials(2, 1) + ");\n"
        return s



class GammaRayAngularDistributionDegreesB2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Gamma Ray Angular Distribution (degrees) B"
    _HTML = "y = A0 + A2 * P<sub>2</sub>(cos(theta)) + A4 * P<sub>4</sub>(cos(theta))"
    coefficientDesignatorTuple = ('A0', 'A2', 'A4')
    LinearSSQSolverFlag = 1
    function_cpp_code = 'temp = coeff[0] + coeff[1] * _id[_cwo[1]+i] + coeff[2] * _id[_cwo[2]+i];'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreCosineDegreesX(NameOrValueFlag=1, args=[2]), [2]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreCosineDegreesX(NameOrValueFlag=1, args=[4]), [4]])


    def SpecificCodeCPP(self):
        s  = "\t// see http://en.wikipedia.org/wiki/Legendre_polynomials\n"
        s += "\ttemp += A0 + A2 * (" + cppCodeGeneratorForLegendrePolynomials(2, 1) + ") + A4 * (" + cppCodeGeneratorForLegendrePolynomials(4, 1) + ");\n"
        return s



class GammaRayAngularDistributionRadiansA2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Gamma Ray Angular Distribution (radians) A"
    _HTML = "y = A0 + A2 * P<sub>2</sub>(cos(theta))"
    coefficientDesignatorTuple = ('A0', 'A2')
    LinearSSQSolverFlag = 1
    function_cpp_code = 'temp = coeff[0] + coeff[1] * _id[_cwo[1]+i];'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreCosineRadiansX(NameOrValueFlag=1, args=[2]), [2]])


    def SpecificCodeCPP(self):
        s  = "\t// see http://en.wikipedia.org/wiki/Legendre_polynomials\n"
        s += "\ttemp += A0 + A2 * (" + cppCodeGeneratorForLegendrePolynomials(2, 1) + ");\n"
        return s



class GammaRayAngularDistributionRadiansB2D(pythonequations.EquationBaseClasses.Equation2D):
    RequiresAutoGeneratedGrowthAndDecayForms = False
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = False
    RequiresAutoGeneratedInverseForms = False
    _name = "Gamma Ray Angular Distribution (radians) B"
    _HTML = "y = A0 + A2 * P<sub>2</sub>(cos(theta)) + A4 * P<sub>4</sub>(cos(theta))"
    coefficientDesignatorTuple = ('A0', 'A2', 'A4')
    LinearSSQSolverFlag = 1
    function_cpp_code = 'temp = coeff[0] + coeff[1] * _id[_cwo[1]+i] + coeff[2] * _id[_cwo[2]+i];'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Ones(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreCosineRadiansX(NameOrValueFlag=1, args=[2]), [2]])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_LegendreCosineRadiansX(NameOrValueFlag=1, args=[4]), [4]])


    def SpecificCodeCPP(self):
        s  = "\t// see http://en.wikipedia.org/wiki/Legendre_polynomials\n"
        s += "\ttemp += A0 + A2 * (" + cppCodeGeneratorForLegendrePolynomials(2, 1) + ") + A4 * (" + cppCodeGeneratorForLegendrePolynomials(4, 1) + ");\n"
        return s
